<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>蜗牛商城后台管理系统_登录页面</title>
<base href="${base}/manage/" />
<base href="${base}/manager/" />
<link rel="stylesheet" type="text/css"
	href="../bootstrap/css/bootstrap.min.css" />
<script src="../js/jquery-3.5.1.min.js"></script>
<script src="../bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
	<div style="height: 100px"></div>
	<!-- 登录面板 -->
	<div class="col-md-push-4 col-md-4 panel text-center">
		<!-- 面板标题 -->
		<div class="panel-heading panel-primary bg-primary">
			<h3>欢迎登录蜗牛商城后台管理系统</h3>
		</div>
		<!-- 面板主体 -->
		<div class="panel-body panel-info bg-info">
			<!-- 登录信息表单 -->
			<form id="loginForm"
				class="form form-horizontal col-md-push-1 col-md-10 ">
				<!-- 账号输入框 -->
				<div class="form-group ">
					<input type="text" name="uaccount" id="uaccount"
						placeholder="请输入管理员账号" class="form-control" />
				</div>
				<!-- 密码输入框 -->
				<div class="form-group ">
					<input type="password" name="upsw" id="upsw" placeholder="请输入密码"
						class="form-control" />
				</div>
				<!-- 提示信息 -->
				<div class="form-group ">
					<span id="msg">&nbsp;</span>
				</div>
				<!-- 操作按钮 -->
				<div class="form-group">
					<button type="submit" class="btn btn-block btn-success"
						id="loginBtn">登录</button>
					<button type="reset" class="btn btn-block btn-warning">重置</button>
				</div>
			</form>
		</div>
		<!-- 面板底部 -->
		<div class="panel-footer bg-warning">
			<h5>版权所有&copy;蜗牛商城后台管理系统</h5>
		</div>
	</div>
</body>
<script type="text/javascript">
	$(document).ready(
			function() {
				//当用户开始输入时，将提示信息消去
				$("input").focus(function() {
					$("#msg").html("&nbsp;");
				})
				//检查账号栏是否为空
				$("#uaccount").blur(function() {
					checkUaccount();
				})
				//检查密码栏是否为空
				$("#upsw").blur(function() {
					checkUpsw();
				})
				//登录操作
				$("#loginBtn").click(
						function(e) {
							e.preventDefault();
							if (checkUaccount() && checkUpsw()) {
								$.ajax({
									url : "../user?opr=adminLogin",
									type : "post",
									data : $("#loginForm").serialize(),
									dataType : "json",
									success : function(result) {
										if (result.msg == "ok") {
											location.href = "welcome.jsp";
										} else {
											$("#msg").html(
													"<font color='red'>"
															+ result.msg
															+ "</font>");
										}
									}
								})
							}
						})
			})

	//检查账号栏是否为空
	function checkUaccount() {
		if ($("#uaccount").val() == "") {
			$("#msg").html("<font color='red'>账号不能为空</font>");
			return false;
		}
		return true;
	}

	//检查密码栏是否为空
	function checkUpsw() {
		if ($("#upsw").val() == "") {
			$("#msg").html("<font color='red'>密码不能为空</font>");
			return false;
		}
		return true;
	}
</script>
</html>
